package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-14
 * Time: 13:57
 */
public class AddOperation implements Operation{
    @Override
    public void work(BookList booklist) {
        Scanner scan = new Scanner(System.in);
        System.out.println("添加书籍：");

        System.out.println("请输入要添加书籍的名称：");
        String name = scan.nextLine();

        System.out.println("请输入要添加书籍的作者：");
        String author = scan.nextLine();

        System.out.println("请输入要添加书籍的类型：");
        String type = scan.nextLine();

        System.out.println("请输入要添加书籍的价格：");
        double price = scan.nextDouble();
        Book book =new Book(name,author,type,price);
        int cursize = booklist.getBooksize();
        booklist.setBooks(cursize,book);
        booklist.setBooksize(cursize+1);
        System.out.println("添加成功！");
    }
}
